import JSEncrypt from 'jsencrypt'

let priKey =
	'-----BEGIN RSA PRIVATE KEY-----MIICXQIBAAKBgQDvupVIIoSGBwdLXqP/ox0YYr1pj7ZmadC7i0mujqzIjpBh/NCJmZWtb4rmZyN18PPcctxIbyndJQ//BrUnFc4v0F4fjciHBuwSBAtaMBjoyj2CBiijHK6H96+cHv+AiudD0Vf3Ij0T7BaLZJZ/Ss3M25mRuT5cYN09M8Bt34Dv2wIDAQABAoGAVJQNqx+Shf7g0fSYA882qq3biezMO6HFpQVlf5KS30d9JTUfFgz7w+8AoH1vA2N5hiN4GI4vxPgYhq+FJj8JOSKAcmaGYnPKUd41yI/07tHMxNuXngJW0AyjhFFloEwp620VZGMzdPqkUMG5JvIViYoXc5yb1bE55l0TOUHUK/ECQQD9BYx4KqlNs9VKdrBla79iqjlgAff8nK542g/pIeKTcin/ARQRxVue/ABHyNnaJY+Ji7fpRACg3u2ECklur1DlAkEA8oz6X2l2xt+lK2bXCJhQ8dI68DGAQZBIwAHNQfTkppZXuTg/EErPo6XgXT3cletQ6+rvF3Dd2lk8loRQ5JzxvwJAdUIxCy+aLqx82HmQ3i/FDlCdLmU7LBLguJk2bnCJtJNf6xHw3xt7jn5zEtF+RJ7Lmo7puG0PbX5izKKHzYfqEQJBALTZGuHDQBW+sWewEUtOTqRP7TQkpI2+KBBKB6JTF52CYbwvzQ23yiQpzSWYt31s7HRLQqRGupRQjxVnaO1ce/8CQQCy65L/c+kqTF3zqrnoaKlScz6D877fsR1MQO3OJdCPkJdKTaGVrtKMazBBp0CN9Z98SJxvqIFizpesQnb+Daq2-----END RSA PRIVATE KEY-----'
// const pubKey = `MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDQaCswD+C3DzMiZZyHIJr5g3Tc5nChFW1o22q46iR2gdt3b45o4XrIdARzTfKYeH/Dcm+K15dbqRtDslW4z09HSwt2Wzta1LAVG/amkz221Ufh60MDuKOCYEUhYelXzd8XNA3nhYdGhznLYllWC9D3hsgWHh/Pwrh/VNPe2eK29QIDAQAB`
const pubKey = `MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDVosnYdJrwa1jo8IAfPhWJk+UFyhAgjBb6ssaCZgGCpZScB7a4nw2S6ePN6JA3GdyId0cU8CKtTI7PxSsdeYA9P3ngn4e7SPalRAr2y3vFJgEo8PGefZtoyu8cZpg25NlCkNJw3hWMs55oZHdRhYiuqxOqYJ72SgLpjQpWxfiGowIDAQAB`
const encodeString = (str: string) => {
  const encrypt  = new JSEncrypt()
  encrypt.setPublicKey(pubKey)
  return encrypt.encrypt(str).toString()
}

const decodeString = (str: string) => {
  const encrypt  = new JSEncrypt()
  encrypt.setPrivateKey(priKey)
  return encrypt.decrypt(str).toString()
}

export const RsaEncrypto = {
  encodeString,
  decodeString
}
